// pages/style/style.js

const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    btn: [],
    patbtn: [],
    imgheight: [],
    paint:[],
    btnheight: [],
    text: [],
    btnClick: []
  },

  mo1: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=11',
    })
  },
  mo2: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=11',
    })
  },

  mo3: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=12',
    })
  },

  mo4: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=13',
    })
  },

  mo5: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=14',
    })
  },

  mo6: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=15',
    })
  },

  mo7: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=20',
    })
  },

  mo8: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=22',
    })
  },

  mo9: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=23',
    })
  },

  mo10: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=25',
    })
  },

  mo11: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=26',
    })
  },

  mo12: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=27',
    })
  },

  mo13: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=28',
    })
  },

  mo14: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=29',
    })
  },

  mo15: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=30',
    })
  },

  mo16: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=31',
    })
  },

  mo17: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=32',
    })
  },

  bi1: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=5',
    })
  },
  bi2: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=8',
    })
  },
  bi3: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=9',
    })
  },
  bi4: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=10',
    })
  },
  bi5: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=16',
    })
  },
  bi6: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=17',
    })
  },
  bi7: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=18',
    })
  },
  bi8: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=19',
    })
  },
  bi9: function(){
    wx.navigateTo({
      url: '/pages/detail/detail?pId=24',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var from = options.from;
    var paints = [];
    var patBtn = [];
    var imgHeight = [];
    var btnHeight = [];
    var Btn=[];

    if(from == "mo"){
      wx.request({
        url: `${app.globalData.url}/painting/?pStyle=水墨`,
        success: res=>{
          var arr = res.data.data;
          for(var i=0; i<arr.length; i++){
            console.log(arr[i].pId)
            paints.push(`${app.globalData.url}/pContent/?pId=${arr[i].pId}`);
            if(i==7){
              imgHeight.push('650rpx')
              btnHeight.push("650rpx")
            }else if( i==8 ){
              imgHeight.push('1050rpx')
              btnHeight.push("1050rpx")
            }else if(i==14 || i==15){
              imgHeight.push('900rpx')
              btnHeight.push("900rpx")
            }else if(i == 16){
              imgHeight.push('1850rpx')
              btnHeight.push("1850rpx")
            }else{
              imgHeight.push('400rpx')
              btnHeight.push("400rpx")
            }
          }
          for(var i=0; i<17; i++){
            patBtn.push('block');
            Btn.push('flex')
          }
          this.setData({
            paint: paints,
            patbtn: patBtn,
            imgheight: imgHeight,
            btnheight: btnHeight,
            btn: Btn,
            btnClick: ["mo1","mo2","mo3","mo4","mo5","mo6","mo7","mo8","mo9","mo10","mo11","mo12","mo13","mo14","mo15","mo16","mo17"]
          })
        }
      })
    }else if(from == "bi"){
      wx.request({
        url: `${app.globalData.url}/painting/?pStyle=工笔`,
        success: res=>{
          var arr = res.data.data;
          for(var i=0; i<arr.length; i++){
            console.log(arr[i].pId)
            paints.push(`${app.globalData.url}/pContent/?pId=${arr[i].pId}`);
            if(i==1){
              imgHeight.push('200rpx')
              btnHeight.push("200rpx")
            }else if( i==6 || i==8){
              imgHeight.push('1050rpx')
              btnHeight.push("1050rpx")
            }else{
              imgHeight.push('400rpx')
              btnHeight.push("400rpx")
            }
          }
          for(var i=0; i<17; i++){
            if(i<9){
              patBtn.push('block');
              Btn.push('flex')
            }else{
              patBtn.push("none");
              Btn.push("none")
            }
          }
          this.setData({
            paint: paints,
            patbtn: patBtn,
            imgheight: imgHeight,
            btnheight: btnHeight,
            btn: Btn,
            btnClick: ["bi1","bi2","bi3","bi4","bi5","bi6","bi7","bi8","bi9"]
          })
        }
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})